package RandVars;
public class ErlangRandVar extends RandVar {

	int k;
	ExpRandVar expRV;

	public ErlangRandVar(long lambda, int k) {
		super(k/lambda);
		this.k = k;
		expRV = new ExpRandVar(k/mean);
	}
	
	public ErlangRandVar(double lambda, int k, Rng rng) {
		super(k/lambda);
		if (lambda<0){
			throw new IllegalArgumentException();
		}
		this.k = k;
		expRV = new ExpRandVar(1.0/lambda, rng);
	}

	@Override
	public long getLongRV() {
		double sum = 0;
		for (int i=0; i<k; i++){
			sum += expRV.getDoubleRV();
		}
		return Math.round(sum);
	}

}
